package prictice.lesson;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

/**
 * @Package prictice.lesson
 * @Description:
 * @Author elwyn
 * @Date 2017/9/15 0:01
 * @Email elonyong@163.com
 */
public class GetData {
    public static void main(String[] args) {
        File logFile = new File("track.log");
        Random random = new Random();
        String[] host = {"www.taobao.com"};
        String[] sessionId = {"HJKHKJHUIFDISH21312321", "JKHIHNIDFSFDS34535", "FDSFDSFDSFDSMKMK908", "DFSFDSFDSAAAA1123245", "GFGDGFDGHKINNIU778"};
        String[] time = {"2014-01-07 08:40:50", "2014-01-07 08:40:50",
                "2014-02-07 06:40:50", "2014-01-27 06:40:50",
                "2014-03-07 09:40:50", "2014-01-17 11:40:50",
                "2014-04-07 08:40:50", "2014-11-08 12:40:50",
                "2014-05-07 08:40:50"};
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < 50; i++) {
            stringBuffer.append(host[0] + "\t" + sessionId[random.nextInt(5)] + "\t" + time[random.nextInt(9)] + "\n");

        }
        if (!logFile.exists()) {
            try {
                logFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        byte[] bytes = stringBuffer.toString().getBytes();
        FileOutputStream fileOutputStream;
        try {
            fileOutputStream = new FileOutputStream(logFile);
            fileOutputStream.write(bytes);
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
